      SUBROUTINE HBFILL1(nabvoff)

      IMPLICIT NONE
      
      INCLUDE 'hbcomm.inc'
      INCLUDE 'hbtype.inc'

      INTEGER I,J,K,JJ,UN,IERROR,IFILE,NLOOP
      INTEGER NOENT, OFFSET, NABVOFF

      INTEGER sig1p, sig2p, hsb1p,hsb2p,lsb1p,lsb2p;

      REAL DDD

c      REAL ax1, ax2, st1, st2

      PARAMETER (UN=100)

      EQUIVALENCE (ntr,VEC1(1))
      CHARACTER*120 CHFIN(0:2000)
      
      REAL VEC(12), VEC2(8), VEC3(2)

      real p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10
      real p(0:10)
      INTEGER zzz11, zzz21, zzz22
      INTEGER zzz11l, zzz21l, zzz22l
      INTEGER zzz11m, zzz21m, zzz22m
      INTEGER zzz11h, zzz21h, zzz22h
      real weight

      do i=0,10
         p(i)=10**i
      enddo


      CALL HFILL(NABVOFF+100,recm2pi,0.,1.)
c     write(6,*) 2

c     goto 101

      weight=0.

      IF (ABS(recmpi1-10.63)<0.04) weight=1.
      If (ABS(recmpi2-10.63)<0.04) weight=weight+1.
c     If (ABS(recmpi2-10.63)<0.04) weight=1.

      if (weight.eq.0.) then
         goto 99
      ENDIF

      CALL HFILL(NABVOFF+200,recm2pi,0.,weight)

c     add mmpi cut
c     add g cuts here
      sig1p=0.
      sig2p=0.
      hsb1p=0.
      hsb2p=0.
      lsb1p=0.
      lsb2p=0.

      if(recm2pi.gt.9.87.and.recm2pi.lt.9.93) then
         sig1p=1.
      endif
      if(recm2pi.gt.9.93.and.recm2pi.lt.9.95) then
         hsb1p=1.
      endif
      if(recm2pi.gt.9.85.and.recm2pi.lt.9.87) then
         lsb1p=1.
      endif

c     if(recm2pi.gt.10.24.and.recm2pi.lt.10.28) then
      if(recm2pi.gt.10.245.and.recm2pi.lt.10.275) then
         sig2p=1.
      endif
      if(recm2pi.gt.10.28.and.recm2pi.lt.10.3) then
         hsb2p=1.
      endif
      if(recm2pi.gt.10.20.and.recm2pi.lt.10.24) then
         lsb2p=1.
      endif


      zzz11 = 0
      zzz21 = 0
      zzz22 = 0

      zzz11l = 0
      zzz21l = 0
      zzz22l = 0

      zzz11m = 0
      zzz21m = 0
      zzz22m = 0

      zzz11h = 0
      zzz21h = 0
      zzz22h = 0

c     2P -> 1 S photon (675 -> 925 MeV)

c     top two digits of ngam6 (600-700 MeV); 675-687.5
      do k=7,8
         zzz21=zzz21+(mod(ngam6,p(k))-mod(ngam6,p(k-1)))/p(k-1)
      enddo
      
c     take everything from 700 to 800 MeV
      do k=1,8
         zzz21=zzz21+(mod(ngam7,p(k))-mod(ngam7,p(k-1)))/p(k-1)
      enddo

c     take everything from 800 to 900 MeV
      do k=1,8
         zzz21=zzz21+(mod(ngam8,p(k))-mod(ngam8,p(k-1)))/p(k-1)
      enddo
      do k=1,2
         zzz21=zzz21+(mod(ngam9,p(k))-mod(ngam9,p(k-1)))/p(k-1)
      enddo
      

c     675-700 MeV; `zzz21l' == 'zzz' 2->1 transition, left side
      do k=7,8
         zzz21l=zzz21l+(mod(ngam6,p(k))-mod(ngam6,p(k-1)))/p(k-1)
      enddo

c     700-750 MeV
      do k=1,4
         zzz21l=zzz21l+(mod(ngam7,p(k))-mod(ngam7,p(k-1)))/p(k-1)
      enddo

c     750 to 800
      do k=5,8
         zzz21m=zzz21m+(mod(ngam7,p(k))-mod(ngam7,p(k-1)))/p(k-1)
      enddo

c     800 to 850
      do k=1,4
         zzz21m=zzz21m+(mod(ngam8,p(k))-mod(ngam8,p(k-1)))/p(k-1)
      enddo

c     850 to 900
      do k=5,8
         zzz21h=zzz21h+(mod(ngam8,p(k))-mod(ngam8,p(k-1)))/p(k-1)
      enddo

c     850 to 925
      do k=1,2
         zzz21h=zzz21h+(mod(ngam9,p(k))-mod(ngam9,p(k-1)))/p(k-1)
      enddo



c     2P -> 2 S photon (150 -> 350 MeV)
      zzz22=0.

      do k=5,8
         zzz22=zzz22+(mod(ngam1,p(k))-mod(ngam1,p(k-1)))/p(k-1)
      enddo
      do k=1,8
         zzz22=zzz22+(mod(ngam2,p(k))-mod(ngam2,p(k-1)))/p(k-1)
      enddo
      do k=1,4
         zzz22=zzz22+(mod(ngam3,p(k))-mod(ngam3,p(k-1)))/p(k-1)
      enddo


      do k=5,8
         zzz22l=zzz22l+(mod(ngam1,p(k))-mod(ngam1,p(k-1)))/p(k-1)
      enddo
      do k=1,1
         zzz22l=zzz22l+(mod(ngam2,p(k))-mod(ngam2,p(k-1)))/p(k-1)
      enddo
      do k=2,7
         zzz22m=zzz22m+(mod(ngam2,p(k))-mod(ngam2,p(k-1)))/p(k-1)
      enddo
      do k=8,8
         zzz22h=zzz22h+(mod(ngam2,p(k))-mod(ngam2,p(k-1)))/p(k-1)
      enddo
      do k=1,4
         zzz22h=zzz22h+(mod(ngam3,p(k))-mod(ngam3,p(k-1)))/p(k-1)
      enddo


c     1P -> 1 S photon (375 -> 575 MeV)

      zzz11=0.
      do k=7,8
         zzz11=zzz11+(mod(ngam3,p(k))-mod(ngam3,p(k-1)))/p(k-1)
      enddo
      do k=1,8
         zzz11=zzz11+(mod(ngam4,p(k))-mod(ngam4,p(k-1)))/p(k-1)
      enddo
      do k=1,6
         zzz11=zzz11+(mod(ngam5,p(k))-mod(ngam5,p(k-1)))/p(k-1)
      enddo


      do k=7,8
         zzz11l=zzz11l+(mod(ngam3,p(k))-mod(ngam3,p(k-1)))/p(k-1)
      enddo
      do k=1,3
         zzz11l=zzz11l+(mod(ngam4,p(k))-mod(ngam4,p(k-1)))/p(k-1)
      enddo
      do k=4,8
         zzz11m=zzz11m+(mod(ngam4,p(k))-mod(ngam4,p(k-1)))/p(k-1)
      enddo
      do k=1,1
         zzz11m=zzz11m+(mod(ngam5,p(k))-mod(ngam5,p(k-1)))/p(k-1)
      enddo
      do k=2,6
         zzz11h=zzz11h+(mod(ngam5,p(k))-mod(ngam5,p(k-1)))/p(k-1)
      enddo


c     filling histograms for 1P -> 1 S with photon (375 -> 575 MeV)
      offset = 0
      if (zzz11.eq.0) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 1000
      if (zzz11.eq.1) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)

         if (zzz11l.eq.1) then
            call hfill(nabvoff+1001+offset,recm2pi,0.,weight)
         endif
         if (zzz11m.eq.1) then
            call hfill(nabvoff+1002+offset,recm2pi,0.,weight)
         endif
         if (zzz11h.eq.1) then
            call hfill(nabvoff+1003+offset,recm2pi,0.,weight)
         endif

      endif


      offset = 2000
      if (zzz11.eq.2) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif


      offset = 3000
      if (zzz11.eq.1.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 4000
      if (zzz11.eq.1.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 5000
      if (zzz11.eq.1.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 6000
      if (zzz11.eq.0.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif


c     filling histograms for 2P -> 1 S

      offset = 10000
      if (zzz21.eq.0) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 11000
      if (zzz21.eq.1) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)

         if (zzz21l.eq.1) then
            call hfill(nabvoff+1001+offset,recm2pi,0.,weight)
         endif
         if (zzz21m.eq.1) then
            call hfill(nabvoff+1002+offset,recm2pi,0.,weight)
         endif
         if (zzz21h.eq.1) then
            call hfill(nabvoff+1003+offset,recm2pi,0.,weight)
         endif

      endif


      offset = 12000
      if (zzz21.eq.2) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif


      offset = 13000
      if (zzz21.eq.1.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif
      offset = 14000
      if (zzz21.eq.1.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif
      offset = 15000
      if (zzz21.eq.1.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 16000
      if (zzz21.eq.0.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

c     filling histograms for 2P -> 2 S
      offset = 20000
      if (zzz22.eq.0) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 21000
      if (zzz22.eq.1) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)

         if (zzz22l.eq.1) then
            call hfill(nabvoff+1001+offset,recm2pi,0.,weight)
         endif
         if (zzz22m.eq.1) then
            call hfill(nabvoff+1002+offset,recm2pi,0.,weight)
         endif
         if (zzz22h.eq.1) then
            call hfill(nabvoff+1003+offset,recm2pi,0.,weight)
         endif

      endif

      offset = 22000
      if (zzz22.eq.2) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 23000
      if (zzz22.eq.1.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 24000
      if (zzz22.eq.1.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 25000
      if (zzz22.eq.1.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif

      offset = 26000
      if (zzz22.eq.0.and.(ax1+st1).gt.9.and.(ax2+st2).gt.9.and.prob2pi.gt.0.) then
         call hfill(nabvoff+1000+offset,recm2pi,0.,weight)
      endif


 99   continue

      RETURN
      END
